#include<stdio.h>
#include<string.h>
typedef struct student
{
    char name[21];
    int sno;
    double chinese;
    double english;
    double math;
    double sum;
}student;
int main()
{
	student s[20];
	int n;
	int i=0;
	while(1)
	{
		scanf("%s",s[i].name);
		if(strcmp(s[i].name,"exit")==0)
		{
			break;
		}
		scanf("%d %lf %lf %lf",&s[i].sno,&s[i].chinese,&s[i].english,&s[i].math);
		s[i].sum=s[i].chinese+s[i].english+s[i].math;
		i++;
	}
	n=i;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n-i-1;j++)
		{
			if(s[j].sum<s[j+1].sum)
			{
				student t;
				t=s[j];
				s[j]=s[j+1];
				s[j+1]=t;
			}
			else if(s[j].sum==s[j+1].sum)
			{
				if(strcmp(s[j].name,s[j+1].name)>0)
				{
					student t;
					t=s[j];
					s[j]=s[j+1];
					s[j+1]=t;
				}
			}
		}
	}
	printf("[");
	for(int i=0;i<n;i++)
	{
		printf("{name:%s,sum:%lg,sno:%d}",s[i].name,s[i].sum,s[i].sno);
		if(i!=(n-1))
		{
			printf(",");
		}
	}
	printf("]");
	return 0;
} 
